package com.library.utils
{
	public class CheckLink
	{
		public static const URL_TYPE_LINK:String = "Link_Type_Link"
		public static const URL_TYPE_MAIL:String = "Link_Type_Mail"
		public static const URL_TYPE_NUMBER:String = "Link_Type_Number"
		public static const URL_TYPE_NULL:String = "Link_Type_Null"		
		
		private static var _ptnLink:RegExp = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/i;
		private static var _ptnEmail:RegExp = /([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}/;
		private static var _ptnNumber:RegExp = /^\d+$/; // 匹配一个或多个数字
		
		public static function checkURL(url:String):String{
			
			if(_ptnLink.test(url)){
				return URL_TYPE_LINK;
			}else if(_ptnEmail.test(url)){
				return URL_TYPE_MAIL;
			}else if(_ptnNumber.test(url)){
				return URL_TYPE_NUMBER;
			}else{
				return URL_TYPE_NULL;
			}

		}

	}
}